package com.veo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;

@Controller
@SessionAttributes(value = {"username","password"},types = {String.class})
public class SessionAttributeController {

    @RequestMapping("/testPut")
    public String testPut(Model model){
        model.addAttribute("username","fox");
        model.addAttribute("password","fox");
        model.addAttribute("age","123");
        return "success";
    }

    @RequestMapping("/testGet")
    public String testGet(ModelMap map){
        String username = (String) map.get("username");
        String password = (String) map.get("password");
        String age = (String) map.get("age");
        System.out.println(username+":"+password+":"+age);
        return "success";
    }

    @RequestMapping("/testClear")
    public String testClear(SessionStatus sessionStatus){
        sessionStatus.setComplete();
        return "success";
    }
}
